import {
	request,
	get,
	post
} from "@/utils/request.js"

// export function apiGetBanner() {
// 	return request({
// 		url: "/homeBanner"
// 	})
// }

export default {
	userRegisterService: (name, userType, password, phoneNumber, code) => {
		return request({
			url: '/reg',
			method: 'post',
			data: {
				name,
				userType,
				password,
				phoneNumber,
				code
			}
		})
	},
	userLoginService: (phoneNumber, password) => {
		return post('/login', {
			phoneNumber,
			password
		})
	},
	userForgetPassword: (password, phoneNumber, code) => {
		return post('/smsBack', {
			password,
			phoneNumber,
			code
		})
	},
	userGetInfoService: () => {
		return get('/user/currentUserInfo')
	},
	userLogoutService: () => {
		return post('/logout')
	},

	//验证码
	sendCodeLogin: (phone) => {
		return get('/sms/sendCodeLogin?phone=' + phone)
	},
	sendCodeReg: (phone) => {
		return get('/sms/sendCodeReg?phone=' + phone)
	},
	sendCodeBack: (phone) => {
		console.log(phone)
		return get('/sms/sendCodeBack?phone=' + phone)
	},


	// 用户课表获取  其实就拿个id
	getCourseSchedule: () => {
		return get('/chat/allCourseSchedule')
	},

	// 学习计划获取
	getCourseStudyPlan: (fileId) => {
		return get('/chat/courseSuggestion?fileId=' + fileId)
	},

	// 课程关系获取
	getCourseRelation: (fileId) => {
		return get('/chat/courseConnection?fileId=' + fileId)
	},




	//课程   用数组去接课程
	getCourseList: () => {
		return get('/coures/PageIndex')
	},

	// 所有课程id和名字的获取   老师端生成ppt要用
	getCourseName: () => {
		return get('/coures/briefList')
	},

	//课程章节的获取  数组接
	getChapterContent: (courseId) => {
		return get('/selectCouresChapters?couresId=' + courseId)
	},

	// // 光章节名字的获取
	getChapterName: (courseId) => {
		return get('/coures/selectAllFileByCouresId?courseId=' + courseId)
	},
	//课程章节的视频获取
	// getChapterVideo: () => {
	//     return get('/coures/selectAllFileByCouresId?couresId=' + courseId)
	//     //后端返回视频的路径
	// },
	getSingleChapterInfo: (resourceidId) => {
		return get(
			'/coures/selectVideoByResourceidId?courseResourceId=' + resourceidId
		)
	},

	//    记录视频观看进度   这里的allViewTime  改成Now开头了
	recordHistory: (courseId, courseResourceId, nowViewTime) => {
		return post('/coures/viewVideo', {
			courseResourceId,
			nowViewTime,
			courseId
		})
	},
	// getLastHistory: ( resourceidId) => {
	//     return get('/coures/selectLastVideoByResourcesId?resourcesId=' + resourceidId)
	//     //后端返回lastTime即可
	// },   这一块直接合并到章节信息里面了  不需要单独再发一个请求 因为就是加一个字段的事情

	// 记录看到那个视频了  后端那边在我发送点击某个视频的时候 记录下了我点击的那个视频  所以不需要我单独再给他返回当前视频id了
	lastVideo: (videoId) => {
		return post('/coures/viewVideo', {
			videoId
		})
	},
	// 获取上次看到的对应视频
	getLastVideo: (c) => {
		return get('/coures/selectLastVideo?courseId=' + c)
	},

	// 章节
	// getChapterComments
	// 笔记
	getChapterNote: (chapterId) => {
		return get('/doc/DetailByChapterId?courseResourceId=' + chapterId)
	},
	// 保存或更改章节笔记
	saveChapterNote: (note) => {
		return post('/doc/editDoc', note)
	},

	//获取所有笔记
	getAllNote: () => {
		return get('/doc/allTitle')
	},
	//获取笔记详情
	getNoteDetail: (id) => {
		return get('/doc/DetailtById?id=' + id)
	},

	//课程里章节的评论
	// getChapterComment: (chapterId)=> {
	//     return get('/coures/getCourseComment?id='+id)
	// },
	//如果页面中的评论进行了封装 成为comment  那么这里的参数也就写成这个comment就行？两者各自优势是？这个是更加灵活吗？ 可以自己选择传什么 和不传什么？
	postChapterComment: (courseId, courseResourceId, context) => {
		return post('/coures/editCouresChapterComments', {
			courseId,
			courseResourceId,
			context
		})
	},
	loadChapterComment: (chapterId) => {
		return get(
			'/coures/selectCouresChapterComments?courseResourceId=' + chapterId
		)
	},

	// 思维导图的数据获取
	getMindMap: (videoUrl) => {
		return get('/videoContentMindMap?videoUrl=' + videoUrl)
	},

	//作业

	//个人中心
	updateUserInfo: (userInfo) => {
		return post('/user/completeInfo', userInfo)
	},

	// 首页课程一级分类名字的获取

	getFirstCategorys: () => {
		return get('/couresCategory/list2')
	},

	// 首页获取图片轮播数据
	getSliders: () => {
		return get('/')
	},

	//查询课程标签（知识点）
	tagsList: (categoryFatherId) => {
		return get(
			'/couresCategory/list1?categoryFatherId=' + categoryFatherId
		)
	},

	//拿到选择兴趣的一级和二级的兴趣标签
	getAllTags: () => {
		return get('/couresCategory/list3')
	},

	// 获取单个课程分类对应的学习路线的markdown数据
	getCategoryMarkdown: (categoryId) => {
		return get(
			'/couresCategory/categoryLearningRoute?categoryId=' + categoryId
		)
	},

	// 用户选择的兴趣标签传给后端
	interestTag: (ids) => {
		return post('/couresCategory/addInterests', ids)
	},

	// // 获取用户选择的兴趣标签   这个的作用是用户下次登录的时候  可以拿到用户选择的兴趣标签
	// getUserInterest: () => {
	//     return get('/couresCategory/getInterests')
	// },

	// 查询兴趣的分类标签
	interestTagSelect: () => {
		return get('/couresCategory/getInterests')
	},

	// 点击分类的某个兴趣标签查询对应课程
	getCourseByInterest: (interestId) => {
		return get('/couresCategory/queryByCategoryId?id=' + interestId)
	},

	//添加/删除个人课程，如果原来已添加，则改为未添加，如果原来未添加，则改为已添加
	saveUserLike: (courseId) => {
		return get('/coures/joinCoures?courseId=' + courseId)
	},

	// 个人课程的获取    如果是老师返回管理的课程，如果是学生返回所在的课程  这里也是老师获取课程的接口

	getUserCourse: () => {
		return get('/coures/all')
	},

	// 课程简介的单独获取
	getSingleCourseIntroduce: (courseId) => {
		return get('/coures/courseIntroduction?courseId=' + courseId)
	},

	// 课程完整规范的章节目录获取
	getCourseCatalog: (courseId) => {
		return get('/coures/selectAllChapterByCouresId?courseId=' + courseId)
	},

	// ai对话
	//发送消息
	sendMessage: (message, sid) => {
		return post('/chat/' + sid + '/sendMessage', message)
	},

	// 历史会话记录
	getHistory: () => {
		return get('/chat/allHistory')
	},

	// 指定历史会话
	getHistoryById: (id) => {
		return get('/chat/queryHistoryBySid?sid=' + id)
	},

	// 不传id 那么默认拿到上一次的会话  如果没有 后端返回data为null
	getHistoryLatest: () => {
		return get('/chat/queryHistoryBySid')
	},

	// 新建会话
	getNewSession: () => {
		return get('/chat/newSession')
	},

	// 文档问答模式
	getDocMessage: (question, fileIds, sid) => {
		return post(
			'/chat/chatWithFiles?fileIds=' + fileIds + '&sid=' + sid,
			question
		)
	},

	// 课程问答模式
	getCourseMessage: (question, courseResourceId, sid) => {
		return post(
			'/chat/chatWithCourse?courseResourceId=' +
			courseResourceId +
			'&sid=' +
			sid,
			question
		)
	},

	// 上传的历史文档
	getUploadDoc: () => {
		return get('/chat/allFileTitleList')
	},
	//评论内容精选总结
	getCommentSummary: (courseResourceId) => {
		return get(
			'/coures/courseCommentSummary?courseResourceId=' + courseResourceId
		)
	},

	// ai视频内容总结 如果之前总结过的话  那就是  固定的  数据库存好的了
	getVideoSummary: (videoUrl, flag) => {
		return get('/videoContent?videoUrl=' + videoUrl + '&flag=' + flag)
	},

	// ai视频内容总结  不管之前有无总结 直接现场生成
	getVideoSummary2: (videoUrl, flag) => {
		return get('/videoContent2?videoUrl=' + videoUrl + '&flag=' + flag)
	},

	// 针对个人用户的当前进度总结
	getVideoCurrentPlanSummary: (courseResourceId) => {
		return get(
			'/videoContentOnlyUser?courseResourceId=' + courseResourceId
		)
	},
	// 用户重复观看的视频对应时间分析
	// getVideoAnalysis: (courseResourceId,time) => {
	//     return get('/coures/analysisKnowledge?')
	// },

	// 用户回退或跳转视频进度时把时间 和章节资源id返回回去 并响应一个是否重复观看的标志
	getIsRepeatWatch: (courseResourceId, time) => {
		return get(
			'/coures/userJump?courseResourceId=' + courseResourceId + '&time=' + time
		)
	},

	// 用户重复观看的时间段的视频分析  拖动进度条的
	getVideoAnalysis: (courseResourceId) => {
		return get(
			'/coures/analysisViewingRecords?courseResourceId=' + courseResourceId
		)
	},

	// 点击ai解答视频观看中遇到问题
	getVideoAnswer: (courseResourceId, question, time) => {
		return get(
			'/coures/courseQuestionsAndAnswers?courseResourceId=' +
			courseResourceId +
			'&question=' +
			question +
			'&time=' +
			time
		)
	},

	// 对ai分析不准的意见反馈
	getAISuggestion: (courseResourceId, feedbackAndSuggestion) => {
		return get(
			'/coures/feedbackAndSuggestion?courseResourceId=' +
			courseResourceId +
			'&feedbackAndSuggestion=' +
			feedbackAndSuggestion
		)
	},

	// 个人小结数据的获取
	getPersonalSummary: (courseResourceId) => {
		return get(
			'/student/learningSituationAnalysis?courseResourceId=' + courseResourceId
		)
	},

	// 章节文档获取
	getChapterDocument: (courseResourceId) => {
		return get('/uplodaFilesList?courseResourceId=' + courseResourceId)
	},

	// 检测分心
	getAttention: (base64String1, nowViewTime, courseResourceId) => {
		// return get('/student/detectDistraction?base64String=' + base64String)
		return post('/student/detectDistraction', {
			base64String1,
			nowViewTime,
			courseResourceId
		})
	},

	// 获取问题列表  困惑监测
	getQuestionList: (courseResourceId, time) => {
		return get(
			'/coures/videoCaption?courseResourceId=' +
			courseResourceId +
			'&time=' +
			time
		)
	},

	// 点击困惑监测需要按钮 发送和请求数据
	postKunHuo: (courseResourceId, questionId, time) => {
		return post('/coures/courseQuestions', {
			courseResourceId,
			questionId,
			time
		})
	},

	// 视频互动问答提交作答数据
	postHuDong: (question, answer, referenceAnswer, courseResourceId, time) => {
		return post('/coures/answerQuestion', {
			question,
			answer,
			referenceAnswer,
			courseResourceId,
			time
		})
	},

	// 搜索课程的获取
	getSearchCourse: (name) => {
		return get('/coures/selectCouresByName?name=' + name)
	},

	// 笔记润色

	getNoteCorrection: (title, sumUp, text, courseResourceId) => {
		return post('/doc/textReWriting', {
			title,
			sumUp,
			text,
			level: 6,
			courseResourceId
		})
	},
	// 笔记纠错

	getNoteErrorCorrection: (title, sumUp, text) => {
		return post('/doc/correct', {
			title,
			sumUp,
			text
		})
	},

	// 历史课程
	getHistoryCourse: () => {
		return get('/coures/selectCouresHistory')
	},

	// 文本翻译
	postTextTranslation: (sourceText, fromType, toType) => {
		return post('/translate/translateText', {
			sourceText,
			fromType,
			toType
		})
	},

	// 语音翻译

	postVoiceTranslation: (audio) => {
		return post('/translate/translateAudio', audio, {
			headers: {
				'Content-Type': 'multipart/form-data'
			}
		})
	},

	// 学生作业查询
	getStudentHomework: (status) => {
		return get('/student/selectAllHomeWorks?status=' + status)
	},

	// 学生作业提交
	postStudentHomework: (homework) => {
		return post('/student/submitHomeWork', homework)
	},

	//  作业题目分析  思路
	getHomeworkAnalysis: (homeWorkId) => {
		return get('/student/jobThinkingAnalysis?homeWorkId=' + homeWorkId)
	},

	// 学生每日在线学习时长  具体的   小时
	getStudentLearningTime: (day) => {
		return post('/student/studyTimeDay', {
			day
		})
	},

	//学生每周在线学习时长   7天  每天的学习时长为单位
	getStudentLearningTimeWeek: (day) => {
		return post('/student/studyTimeWeek', {
			day
		})
	},

	// 各科目学习时长占比

	getStudentLearningTimeSubject: () => {
		return get('/student/subjectStudyTime')
	},

	// 各科目成绩
	getStudentSubjectScore: () => {
		return get('/student/studentAverageScore')
	},

	// 学生测评的ai建议
	getStudentAISuggestion: () => {
		return get('/student/aiSuggestion')
	},

	// 视频AI字幕
	getVideoSubtitle: async (courseResourceId) => {
		// return await get('/coures/videoCaptionReturn?courseResourceId=' + courseResourceId)
		const response = await get(
			'/coures/videoCaptionReturn?courseResourceId=' + courseResourceId
		)
		return response.data.data
	},

	// 学习计划创建
	postStudyPlan: (startTime, delayTime, learningTime) => {
		return post('/student/learningPlanCreating', {
			startTime,
			delayTime,
			learningTime
		})
	},

	// 学习计划查询
	getStudyPlan: () => {
		return get('/student/selectLearningPlan')
	},

	// 设置学习方式   专注时长的
	postStudyWay: (studyTime, customStudyTime, restTime, customRestTime) => {
		return post('/student/setLearningMethod', {
			studyTime,
			customStudyTime,
			restTime,
			customRestTime
		})
	},

	// 查询学习方式   专注时长的
	getStudyWay: () => {
		return get('/student/selectLearningMethod')
	},

	// 搜索接口 推荐外部资源  哔站的
	searchExternal: (learningContent) => {
		return get(
			'/student/learningContentRecommendation?learningContent=' +
			learningContent
		)
	},

	// 发送选择的引擎
	postEngine: (searchEngine) => {
		return get(
			'/student/updateSearchEngine-' + searchEngine
		)
	},
	// 获取到之前选择的搜索引擎，没有就默认本地
	getEngine: () => {
		return get('/student/selectSearchEngine')
	},

	// 获取走神照片等数据
	getPictureZouShen: (courseResourceId) => {
		return get('/student/mindWanderingPhoto?courseResourceId=' + courseResourceId)
	},

	// 学习路线
	// 查询学习路线目录
	getStudyPathList: () => {
		return get("/chat/learningPathCategory")
	},
	// 查询学习路线具体信息
	getStudyPathDetailById: (id) => {
		return get('/chat/learningPathInfo?learningPathId=' + id)
	},
	// 根据要求生成学习路线
	createStudyPath: (require) => {
		return get("/chat/generateLearningPath?require=" + require)
	},

	// 老师端
	// 获取课程和章节信息
	getCourseAndChapter: () => {
		return get('/teacher/selectAllCourse')
	},

	//  课程发布
	postCourse: (course) => {
		return post('/coures/edit', course)
	},
	//作业发布   也是作业数据响应
	homeworkPost: (homework) => {
		return post('/teacher/editHomeWork', homework)
	},

	//指定作业数据查询
	selectHomework: (courseId, courseResourceId) => {
		return get(
			'/teacher/selectHomeWork?courseId=' +
			courseId +
			'&courseResourceId=' +
			courseResourceId
		)
	},

	// 返回当前老师管理的所有学生信息
	selectAllStudent: () => {
		return get('/teacher/selectAllUser')
	},

	// 作业提交情况查询
	selecHomeworkSubmit: () => {
		return get('/teacher/selectAllStudentReplys')
	},

	// 查询老师管理的班级信息
	selectClassInfo: () => {
		return get('/class/selectClass')
	},

	// 老师或学生获取对应单个课程信息
	getCourseInfo: (courseId) => {
		return get('/coures/getCouresById?courseId=' + courseId)
	},

	// 根据作业id查询作业完成的数据
	getHomeworkData: (homeWorkId) => {
		return get(
			'/teacher/selectStudentReplysById?homeWorkId=' + homeWorkId
		)
	},

	// 人工作业评分
	personalCorrect: (homeWorkReplyld, comment, score) => {
		return get(
			'/teacher/assignmentGrading?homeWorkReplyId=' +
			homeWorkReplyld +
			'&comment=' +
			comment +
			'&score=' +
			score
		)
	},

	// ai作业评分
	aiCorrect: (homeWorkReplyld) => {
		return get(
			'/teacher/assignmentGradingSuggestion?homeWorkReplyId=' + homeWorkReplyld
		)
	},

	// ai生成作业
	aiGenerate: (courseId, courseResourceId, prompt) => {
		return post(
			'/teacher/aiGenerateHomeWork?courseId=' +
			courseId +
			'&courseResourceId=' +
			courseResourceId +
			'&prompt=' +
			prompt
		)
	},

	// 获取ppt模版
	getPPT: () => {
		return get('/allTemplate')
	},

	//根据key获取ppt图片地址
	getPPTImage: (key) => {
		return get('/getImageByKey?key=' + key)
	},

	// 创建ppt  自定义
	createPPT: (ppt) => {
		return post('/createPPT', ppt)
	},

	// 创建ppt 根据课程

	createPPTByCourse: (course) => {
		return post('/createPPTByCourseChapter', course)
	}
}